Relational database instruction validation

ABSTRACT

In an example, a database system may be configured to validate relational database instructions using a plurality of validators. In some examples, validation may be pre-production for relational database instructions based on simulated user inputs and/or file, such as plan files (e.g., PL/SQL (procedural language/structured query language) files). In some examples, validation may be in production for relational database instructions based on system views of a database engine.

COPYRIGHT NOTICE

A portion of the disclosure of this patent document contains materialwhich is subject to copyright protection. The copyright owner has noobjection to the facsimile reproduction by anyone of the patent documentor the patent disclosure, as it appears in the United States Patent andTrademark Office patent file or records, but otherwise reserves allcopyright rights whatsoever.

TECHNICAL FIELD

One or more implementations relate generally to databases, and someembodiments relate to relational database instruction validation.

DESCRIPTION OF THE RELATED ART

SQL (structured query language) is a programming language to manage dataof a relational database. Some relational databases may include morethan one table populated with data.

A relational database instruction (e.g., a SQL statement, an SQL query,or the like, or combinations thereof) may cause the relational databaseto perform selected table operations for selected tables. Depending onthe combination of table operations and/or tables involved with a givenrelational database instruction, the given relational databaseinstruction may require minimal to significant database system resources(e.g., processing resources) for responding to the instruction. Someknown relational database schemes may rely on access limitations torelational database access as a partial solution to attempt to preventdatabase system resources from being over utilized.

BRIEF DESCRIPTION OF THE DRAWINGS

The included drawings are for illustrative purposes and serve to provideexamples of possible structures and operations for the disclosedinventive systems, apparatus, methods and computer-readable storagemedia. These drawings in no way limit any changes in form and detailthat may be made by one skilled in the art without departing from thespirit and scope of the disclosed implementations.

FIG. 1A shows a block diagram of an example environment in which anon-demand database service can be used according to someimplementations.

FIG. 1B shows a block diagram of example implementations of elements ofFIG. 1A and example interconnections between these elements according tosome implementations.

FIG. 2 illustrates a database system for relational database instructionvalidation.

FIG. 3 illustrates a process that may be performed by the databasesystem of FIG. 2, in some embodiments.

FIG. 4 illustrates another database system for relational databaseinstruction validation.

FIG. 5 illustrates a process that may be performed by the databasesystem of FIG. 4, in some embodiments.

FIG. 6 illustrates yet another database system for relational databaseinstruction validation.

FIG. 7 illustrates a process that may be performed by the databasesystem of FIG. 6, in some embodiments.

DETAILED DESCRIPTION

Examples of systems, apparatus, computer-readable storage media, andmethods according to the disclosed implementations are described in thissection. These examples are being provided solely to add context and aidin the understanding of the disclosed implementations. It will thus beapparent to one skilled in the art that the disclosed implementationsmay be practiced without some or all of the specific details provided.In other instances, certain process or method operations also referredto herein as “blocks,” have not been described in detail in order toavoid unnecessarily obscuring the disclosed implementations. Otherimplementations and applications also are possible, and as such, thefollowing examples should not be taken as definitive or limiting eitherin scope or setting.

In the following detailed description, references are made to theaccompanying drawings, which form a part of the description and in whichare shown, by way of illustration, specific implementations. Althoughthese disclosed implementations are described in sufficient detail toenable one skilled in the art to practice the implementations, it is tobe understood that these examples are not limiting, such that otherimplementations may be used and changes may be made to the disclosedimplementations without departing from their spirit and scope. Forexample, the blocks of the methods shown and described herein are notnecessarily performed in the order indicated in some otherimplementations. Additionally, in some other implementations, thedisclosed methods may include more or fewer blocks than are described.As another example, some blocks described herein as separate blocks maybe combined in some other implementations. Conversely, what may bedescribed herein as a single block may be implemented in multiple blocksin some other implementations. Additionally, the conjunction “or” isintended herein in the inclusive sense where appropriate unlessotherwise indicated; that is, the phrase “A, B or C” is intended toinclude the possibilities of “A,” “B,” “C,” “A and B,” “B and C,” “A andC” and “A, B and C.”

Some implementations described and referenced herein are directed tosystems, apparatus, computer-implemented methods and computer-readablestorage media for relational database instruction validation.

In some examples, a database system includes a module to identifyrelational database instruction (e.g., SQL (structured query language)code) responsive to receipt of a user request, e.g., a customer request(in some database systems, the module may be part of an applicationserver). The module may call a block of SQL code predefined in an SQLscript responsive to the user input and/or generate SQL textdynamically. The identified relational database instruction may bepassed to a database engine of the database system. However, theidentified relational database instruction may include code that mayrequire significant resources of the database engine because of the typeof table operation(s) included in the instruction and/or attributes ofthe tables associated with operation(s) of the instruction. In someexamples, the database system includes a validation module to receive arelational database instruction as an input and to output validationindication(s) responsive to the input.

In some examples, the validation module may include one or moreparser-based validators. Some parser-based validators may be configuredto parse SQL text into a parse tree and identify elements, e.g.,predefined elements, in the parse tree such as tables, columns infilters, columns in join conditions, hints, or the like, or combinationsthereof. These parser-based validators may be configured to use arule-based validation checking responsive to identification of theelements. In some examples, the rule based validation may be to meetrequirements of the database system (e.g., requirements of the databaseengine and/or the application server), and may include leading indexchecking, index hint checking, table hint checking, or the like, orcombinations thereof.

In some examples, the validation module may include one or more planvalidators, such as ExplainPlan-based validators. Some plan validatorsmay be to exchange communications with the database engine to obtain anexplain plan of the input relational database instruction as a plan treestructure. The plan validators may identify nodes in the plan treestructure based on predefined table operations such as FullScan,FullIndexScan, NestedLoopJoin, HashJoin, or the like, or combinationsthereof. Some plan validators may include a tree transformer module toparse the relational database instruction into a parse tree to extractinformation such as filter columns, join columns, table names, tablealias, or the like, or combinations thereof, in order to identify thenodes.

The plan validators may be configured to validate the identifiedrelational database instruction based on the identified nodes accordingto a rule-based approach. For instance, the validation may check whetherpredefined table operations, such as FullScan and/or FullIndexScan, areused with an underlying table larger than a predefined threshold (andoutput an identification of an error and/or performance issue if so).The validation may check whether predefined table operations, such asNestedLoop, are associated with a valid index for the columns that areparticipating in the joins (and output an identification of an errorand/or performance issue if not). The validation check may check whethera predefined table operation, such as HashJoin with users or ownerstable, includes a valid filter (and output an identification of an errorand/or performance issue if not). The validation may check whether apredefined table operation, e.g., SemiJoin and/or AntiJoin, isconsistent between the plan tree node and the join hint given in therelational database instruction (and output an identification of anerror and/or performance issue if not). If the join hint indicates oneof Semijoin or Antijoin in an SQL statement, but the validatoridentifies an indication of the other of the Semijoin or Antijoin in theplan tree, then the validator may output an indication of theinconsistency (e.g., an error, performance issue, or the like, orcombinations thereof).

The validation module may be configured to output an indication when anerror and/or performance issue is detected based on the validation. Insome examples, the validation module or another module may automaticallyfile a bug report with detailed reasoning about the error and/orperformance issue, which may be used by developers to, for instance,modify the module to identify a relational database instruction of theapplication server.

In some examples, the database system may obtain a candidate relationaldatabase instruction to be input into the validation module using one ormore modules. In some examples, the aforementioned module to identifyrelational database instruction(s) responsive to a user input(hereinafter a “relational database instruction identification module”)may be used to obtain the candidate relational database instruction. Inparticular, a module of the database system may generate a simulateduser input and feed the simulated user input into the relationaldatabase instruction identification module to obtain a candidaterelational database instruction to be input into the validation module.

In some examples, the database system may include a transformationmodule, e.g., an Oracle parser, to extract a candidate relationaldatabase instruction from a plan file (e.g., a PL/SQL file). Thetransformation module may output transformation information that isusable by the plan validators to obtain the explain plan for therelational database instruction (in some examples, an explain plan maybe obtainable for only about 1% or less of relational databaseinstruction without the transformation information, and as such thetransformation module be used with some types of the plan validators(such as a join-type plan validator)). In some examples, thetransformation module may implement a tree transformer on the parsetrees to identify tables and columns associated with the filters andjoins. The plan validators (e.g., a NestedLoop plan validator, aHashJoin validator, a SemiJoin validator, an AntiJoin validator, or thelike, or combinations thereof) may utilize a portion of thetransformation information that is based on the identified tables andcolumns for validation.

An output of the validation module for the candidate relational databaseinstruction obtained responsive to inputting the simulated user inputinto the relational database instruction identification module and/orthe transformation module may prevent a relational database instructionbased on actual user inputs from reaching the database engine (andavoiding the associated performance impact). This may enable thedevelopers to create different plan files and/or modify the relationaldatabase instruction identification module, and release the differentplan files and/or modified relational database instructionidentification module to production (e.g., for customer use).

Besides validating relational database instructions in an “offline”scenario (for instance validating originating candidate relationaldatabase instructions from simulated user inputs or plan files), someexamples may utilize some of the aforementioned modules for relationaldatabase instruction validation “in production”. The database system mayinclude a production run module to obtain relational databaseinstructions based on actual user inputs (e.g., provided by therelational database instruction identification modules responsive tocustomer inputs/requests). In some examples, the production run modulemay run a background check at scheduled intervals; say periodicintervals, to check relational database instructions running through thedatabase engine. In particular, the production run module may obtainrelational database instructions based on system views collected at thescheduled intervals.

The production run module may select validators of the validation module(e.g., all of the validators or a subset of the validators) for a givenobtained relational database instruction, and provide that instructionto the selected validators. In some examples, the production run modulemay input all non-duplicate relational database instructions into asubset of the validators, such as the syntax validators. The productionrun module may input non-duplicate relational database instructions intoanother subset of the validators, such as one or more of the planvalidators, conditionally. For example, in some embodiments theproduction run module may utilize the plan validators at ones of theintervals that correspond to off-peak operation of the database engine(when less customer input/requests to, for instance the database engine,are expected).

The production run module may include a logging and/or monitoring moduleto send information to another database system module such as splunkand/or an optimizer metrics store for future analysis. In some examples,an automated analysis associated with splunk and/or the optimizermetrics store may identify access to the database system bynon-authorized users, thus allowing the non-authorized access to beaddressed to stop an attack and/or restore database engine performance.In some examples, a developer may utilize information obtained by theproduction run module to create new plan files and/or to modify therelational database instruction identification module to optimizedatabase engine operation/performance.

To summarize, some of the database systems described above can generateinformation that may be used (by developers or automatically by a moduleof the database system) to modify plan files and/or an applicationserver (e.g., a relational database instruction identification module ofthe application server) so that performance of the database system isoptimized prior to production. In production, some of the databasesystems described above may determine whether to run a validation at ascheduled time. At these validations, information may be generated thatmay be used (by developers or automatically by a module of the databasesystem) to detect unauthorized access to the database system and/or maybe used to detect performance issues before those performance issuesimpact users of the database system (such as before the performanceissues are noticed by customers).

I. Example System Overview

FIG. 1A shows a block diagram of an example of an environment 10 inwhich an on-demand database service can be used in accordance with someimplementations. The environment 10 includes user systems 12, a network14, a database system 16 (also referred to herein as a “cloud-basedsystem”), a processor system 17, an application platform 18, a networkinterface 20, tenant database 22 for storing tenant data 23, systemdatabase 24 for storing system data 25, program code 26 for implementingvarious functions of the system 16, and process space 28 for executingdatabase system processes and tenant-specific processes, such as runningapplications as part of an application hosting service. In some otherimplementations, environment 10 may not have all of these components orsystems, or may have other components or systems instead of, or inaddition to, those listed above.

In some implementations, the environment 10 is an environment in whichan on-demand database service exists. An on-demand database service,such as that which can be implemented using the system 16, is a servicethat is made available to users outside of the enterprise(s) that own,maintain or provide access to the system 16. As described above, suchusers generally do not need to be concerned with building or maintainingthe system 16. Instead, resources provided by the system 16 may beavailable for such users' use when the users need services provided bythe system 16; that is, on the demand of the users. Some on-demanddatabase services can store information from one or more tenants intotables of a common database image to form a multi-tenant database system(MTS). The term “multi-tenant database system” can refer to thosesystems in which various elements of hardware and software of a databasesystem may be shared by one or more customers or tenants. For example, agiven application server may simultaneously process requests for a greatnumber of customers, and a given database table may store rows of datasuch as feed items for a potentially much greater number of customers. Adatabase image can include one or more database objects. A relationaldatabase management system (RDBMS) or the equivalent can execute storageand retrieval of information against the database object(s).

Application platform 18 can be a framework that allows the applicationsof system 16 to execute, such as the hardware or software infrastructureof the system 16. In some implementations, the application platform 18enables the creation, management and execution of one or moreapplications developed by the provider of the on-demand databaseservice, users accessing the on-demand database service via user systems12, or third party application developers accessing the on-demanddatabase service via user systems 12.

In some implementations, the system 16 implements a web-based customerrelationship management (CRM) system. For example, in some suchimplementations, the system 16 includes application servers configuredto implement and execute CRM software applications as well as providerelated data, code, forms, renderable web pages and documents and otherinformation to and from user systems 12 and to store to, and retrievefrom, a database system related data, objects, and Web page content. Insome MTS implementations, data for multiple tenants may be stored in thesame physical database object in tenant database 22. In some suchimplementations, tenant data is arranged in the storage medium(s) oftenant database 22 so that data of one tenant is kept logically separatefrom that of other tenants so that one tenant does not have access toanother tenant's data, unless such data is expressly shared. The system16 also implements applications other than, or in addition to, a CRMapplication. For example, the system 16 can provide tenant access tomultiple hosted (standard and custom) applications, including a CRMapplication. User third party developer) applications, which may or maynot include CRM, may be supported by the application platform 18. Theapplication platform 18 manages the creation and storage of theapplications into one or more database objects and the execution of theapplications in one or more virtual machines in the process space of thesystem 16.

According to some implementations, each system 16 is configured toprovide web pages, forms, applications, data and media content to user(client) systems 12 to support the access by user systems 12 as tenantsof system 16. As such, system 16 provides security mechanisms to keepeach tenant's data separate unless the data is shared. If more than oneMTS is used, they may be located in close proximity to one another (forexample, in a server farm located in a single building or campus), orthey may be distributed at locations remote from one another (forexample, one or more servers located in city A and one or more serverslocated in city B). As used herein, each MTS could include one or morelogically or physically connected servers distributed locally or acrossone or more geographic locations. Additionally, the term “server” ismeant to refer to a computing device or system, including processinghardware and process space(s), an associated storage medium such as amemory device or database, and, in some instances, a databaseapplication (for example, OODBMS or RDBMS) as is well known in the art.It should also be understood that “server system” and “server” are oftenused interchangeably herein. Similarly, the database objects describedherein can be implemented as part of a single database, a distributeddatabase, a collection of distributed databases, a database withredundant online or offline backups or other redundancies, etc., and caninclude a distributed database or storage network and associatedprocessing intelligence.

The network 14 can be or include any network or combination of networksof systems or devices that communicate with one another. For example,the network 14 can be or include any one or any combination of a LAN(local area network), WAN (wide area network), telephone network,wireless network, cellular network, point-to-point network, starnetwork, token ring network, hub network, or other appropriateconfiguration. The network 14 can include a TCP/IP (Transfer ControlProtocol and Internet Protocol) network, such as the global internetworkof networks often referred to as the “Internet” (with a capital “I”).The Internet will be used in many of the examples herein. However, itshould be understood that the networks that the disclosedimplementations can use are not so limited, although TCP/IP is afrequently implemented protocol.

The user systems 12 can communicate with system 16 using TCP/IP and, ata higher network level, other common Internet protocols to communicate,such as HTTP, FTP, AFS, WAP, etc. In an example where HTTP is used, eachuser system 12 can include an HTTP client commonly referred to as a “webbrowser” or simply a “browser” for sending and receiving HTTP signals toand from an HTTP server of the system 16. Such an HTTP server can beimplemented as the sole network interface 20 between the system 16 andthe network 14, but other techniques can be used in addition to orinstead of these techniques. In some implementations, the networkinterface 20 between the system 16 and the network 14 includes loadsharing functionality, such as round-robin HTTP request distributors tobalance loads and distribute incoming HTTP requests evenly over a numberof servers. In MTS implementations, each of the servers can have accessto the MTS data; however, other alternative configurations may be usedinstead.

The user systems 12 can be implemented as any computing device(s) orother data processing apparatus or systems usable by users to access thedatabase system 16. For example, any of user systems 12 can be a desktopcomputer, a work station, a laptop computer, a tablet computer, ahandheld computing device, a mobile cellular phone (for example, a“smartphone”), or any other Wi-Fi-enabled device, wireless accessprotocol (WAP)-enabled device, or other computing device capable ofinterfacing directly or indirectly to the Internet or other network. Theterms “user system” and “computing device” are used interchangeablyherein with one another and with the term “computer.” As describedabove, each user system 12 typically executes an HTTP client, forexample, a web browsing (or simply “browsing”) program, such as a webbrowser based on the WebKit platform, Microsoft's Internet Explorerbrowser. Apple's Safari, Google's Chrome, Opera's browser, or Mozilla'sFirefox browser, or the like, allowing a user (for example, a subscriberof on-demand services provided by the system 16) of the user system 12to access, process and view information, pages and applicationsavailable to it from the system 16 over the network 14.

Each user system 12 also typically includes one or more user inputdevices, such as a keyboard, a mouse, a trackball, a touch pad, a touchscreen, a pen or stylus or the like, for interacting with a graphicaluser interface (GUI) provided by the browser on a display (for example,a monitor screen, liquid crystal display (LCD), light-emitting diode(LED) display, among other possibilities) of the user system 12 inconjunction with pages, forms, applications and other informationprovided by the system 16 or other systems or servers. For example, theuser interface device can be used to access data and applications hostedby system 16, and to perform searches on stored data, and otherwiseallow a user to interact with various GUI pages that may be presented toa user. As discussed above, implementations are suitable for use withthe Internet, although other networks can be used instead of or inaddition to the Internet, such as an intranet, an extranet, a virtualprivate network (VPN), a non-TCP/IP based network, any LAN or WAN or thelike.

The users of user systems 12 may differ in their respective capacities,and the capacity of a particular user system 12 can be entirelydetermined by permissions (permission levels) for the current user ofsuch user system. For example, where a salesperson is using a particularuser system 12 to interact with the system 16, that user system can havethe capacities allotted to the salesperson. However, while anadministrator is using that user system 12 to interact with the system16, that user system can have the capacities allotted to thatadministrator. Where a hierarchical role model is used, users at onepermission level can have access to applications, data, and databaseinformation accessible by a lower permission level user, but may nothave access to certain applications, database information, and dataaccessible by a user at a higher permission level. Thus, different usersgenerally will have different capabilities with regard to accessing andmodifying application and database information, depending on the users'respective security or permission levels (also referred to as“authorizations”).

According to some implementations, each user system 12 and some or allof its components are operator-configurable using applications, such asa browser, including computer code executed using a central processingunit (CPU) such as an Intel Pentium® processor or the like. Similarly,the system 16 (and additional instances of an MTS, where more than oneis present) and all of its components can be operator-configurable usingapplication(s) including computer code to run using the processor system17, which may be implemented to include a CPU, which may include anIntel Pentium® processor or the like, or multiple CPUs.

The system 16 includes tangible computer-readable media havingnon-transitory instructions stored thereon/in that are executable by orused to program a server or other computing system (or collection ofsuch servers or computing systems) to perform some of the implementationof processes described herein. For example, computer program code 26 canimplement instructions for operating and configuring the system 16 tointercommunicate and to process web pages, applications and other dataand media content as described herein. In some implementations, thecomputer code 26 can be downloadable and stored on a hard disk, but theentire program code, or portions thereof, also can be stored in anyother volatile or non-volatile memory medium or device as is well known,such as a ROM or RAM, or provided on any media capable of storingprogram code, such as any type of rotating media including floppy disks,optical discs, digital versatile disks (DVD), compact disks (CD),microdrives, and magneto-optical disks, and magnetic or optical cards,nanosystems (including molecular memory ICs), or any other type ofcomputer-readable medium or device suitable for storing instructions ordata. Additionally, the entire program code, or portions thereof, may betransmitted and downloaded from a software source over a transmissionmedium, for example, over the Internet, or from another server, as iswell known, or transmitted over any other existing network connection asis well known (for example, extranet, VPN, LAN, etc.) using anycommunication medium and protocols (for example, TCP/IP, HTTP, HTTPS,Ethernet, etc.) as are well known. It will also be appreciated thatcomputer code for the disclosed implementations can be realized in anyprogramming language that can be executed on a server or other computingsystem such as, for example, C, C++, HTML, any other markup language,Java™, JavaScript, ActiveX, any other scripting language, such asVBScript, and many other programming languages as are well known may beused. (Java™ is a trademark of Sun Microsystems, Inc.).

FIG. 1B shows a block diagram of example implementations of elements ofFIG. 1A and example interconnections between these elements according tosome implementations. That is, FIG. 1B also illustrates environment 10,but FIG. 1B, various elements of the system 16 and variousinterconnections between such elements are shown with more specificityaccording to some more specific implementations. Additionally, in FIG.1B, the user system 12 includes a processor system 12A, a memory system12B, an input system 12C, and an output system 12D. The processor system12A can include any suitable combination of one or more processors. Thememory system 12B can include any suitable combination of one or morememory devices. The input system 12C can include any suitablecombination of input devices, such as one or more touchscreeninterfaces, keyboards, mice, trackballs, scanners, cameras, orinterfaces to networks. The output system 12D can include any suitablecombination of output devices, such as one or more display devices,printers, or interfaces to networks.

In FIG. 1B, the network interface 20 is implemented as a set of HTTPapplication servers 100 ₁-100 _(N). Each application server 100, alsoreferred to herein as an “app server”, is configured to communicate withtenant database 22 and the tenant data 23 therein, as well as systemdatabase 24 and the system data 25 therein, to serve requests receivedfrom the user systems 12. The tenant data 23 can be divided intoindividual tenant storage spaces 112, which can be physically orlogically arranged or divided. Within each tenant storage space 112,user storage 114 and application metadata 116 can similarly be allocatedfor each user. For example, a copy of a user's most recently used (MRU)items can be stored to user storage 114. Similarly, a copy of MRU itemsfor an entire organization that is a tenant can be stored to tenantstorage space 112.

The process space 28 includes system process space 102, individualtenant process spaces 104 and a tenant management process space 110. Theapplication platform 18 includes an application setup mechanism 38 thatsupports application developers' creation and management ofapplications. Such applications and others can be saved as metadata intotenant database 22 by save routines 36 for execution by subscribers asone or more tenant process spaces 104 managed by tenant managementprocess 110, for example. Invocations to such applications can be codedusing PL/SOQL 34, which provides a programming language style interfaceextension to API 32. A detailed description of some PL/SOQL languageimplementations is discussed in commonly assigned U.S. Pat. No.7,730,478, titled METHOD AND SYSTEM FOR ALLOWING ACCESS TO DEVELOPEDAPPLICATIONS VIA A MULTI-TENANT ON-DEMAND DATABASE SERVICE, by CraigWeissman, issued on Jun. 1, 2010, and hereby incorporated by referencein its entirety and for all purposes. Invocations to applications can bedetected by one or more system processes, which manage retrievingapplication metadata 116 for the subscriber making the invocation andexecuting the metadata as an application in a virtual machine.

The system 16 of FIG. 1B also includes a user interface (UI) 30 and anapplication programming interface (API) 32 to system 16 residentprocesses to users or developers at user systems 12. In some otherimplementations, the environment 10 may not have the same elements asthose listed above or may have other elements instead of, or in additionto, those listed above.

Each application server 100 can be communicably coupled with tenantdatabase 22 and system database 24, for example, having access to tenantdata 23 and system data 25, respectively, via a different networkconnection. For example, one application server 100 ₁ can be coupled viathe network 14 (for example, the Internet), another application server100 _(N-1) can be coupled via a direct network link, and anotherapplication server 100 _(N) can be coupled by yet a different networkconnection. Transfer Control Protocol and Internet Protocol (TCP/IP) areexamples of typical protocols that can be used for communicating betweenapplication servers 100 and the system 16. However, it will be apparentto one skilled in the art that other transport protocols can be used tooptimize the system 16 depending on the network interconnections used.

In some implementations, each application server 100 is configured tohandle requests for any user associated with any organization that is atenant of the system 16. Because it can be desirable to be able to addand remove application servers 100 from the server pool at any time andfor various reasons, in some implementations there is no server affinityfor a user or organization to a specific application server 100. In somesuch implementations, an interface system implementing a load balancingfunction (for example, an F5 Big-IP load balancer) is communicablycoupled between the application servers 100 and the user systems 12 todistribute requests to the application servers 100. In oneimplementation, the load balancer uses a least-connections algorithm toroute user requests to the application servers 100. Other examples ofload balancing algorithms, such as round robin andobserved-response-time, also can be used. For example, in sonicinstances, three consecutive requests from the same user could hit threedifferent application servers 100, and three requests from differentusers could hit the same application server 100. In this manner, by wayof example, system 16 can be a multi-tenant system in which system 16handles storage of, and access to, different objects, data andapplications across disparate users and organizations.

In one example storage use case, one tenant can be a company thatemploys a sales force where each salesperson uses system 16 to manageaspects of their sales. A user can maintain contact data, leads data,customer follow-up data, performance data, goals and progress data,etc., all applicable to that user's personal sales process (for example,in tenant database 22). In an example of a MTS arrangement, because allof the data and the applications to access, view, modify, report,transmit, calculate, etc., can be maintained and accessed by a usersystem 12 having little more than network access, the user can managehis or her sales efforts and cycles from any of many different usersystems. For example, when a salesperson is visiting a customer and thecustomer has Internet access in their lobby, the salesperson can obtaincritical updates regarding that customer while waiting for the customerto arrive in the lobby.

While each user's data can be stored separately from other users' dataregardless of the employers of each user, some data can beorganization-wide data shared or accessible by several users or all ofthe users for a given organization that is a tenant. Thus, there can besome data structures managed by system 16 that are allocated at thetenant level while other data structures can be managed at the userlevel. Because an MTS can support multiple tenants including possiblecompetitors, the MTS can have security protocols that keep data,applications, and application use separate. Also, because many tenantsmay opt for access to an MTS rather than maintain their own system,redundancy, up-time, and backup are additional functions that can beimplemented in the MTS. In addition to user-specific data andtenant-specific data, the system 16 also can maintain system level datausable by multiple tenants or other data. Such system level data caninclude industry reports, news, postings, and the like that are sharableamong tenants.

In some implementations, the user systems 12 (which also can be clientsystems) communicate with the application servers 100 to request andupdate system-level and tenant-level data from the system 16. Suchrequests and updates can involve sending one or more queries to tenantdatabase 22 or system database 24. The system 16 (for example, anapplication server 100 in the system 16) can automatically generate oneor more SQL statements (for example, one or more SQL queries) designedto access the desired information. System database 24 can generate queryplans to access the requested data from the database. The term “queryplan” generally refers to one or more operations used to accessinformation in a database system.

Each database can generally be viewed as a collection of objects, suchas a set of logical tables, containing data fitted into predefined orcustomizable categories. A “table” is one representation of a dataobject, and may be used herein to simplify the conceptual description ofobjects and custom objects according to some implementations. It shouldbe understood that “table” and “object” may be used interchangeablyherein. Each table generally contains one or more data categorieslogically arranged as columns or fields in a viewable schema. Each rowor element of a table can contain an instance of data for each categorydefined by the fields. For example, a CRM database can include a tablethat describes a customer with fields for basic contact information suchas name, address, phone number, fax number, etc. Another table candescribe a purchase order, including fields for information such ascustomer, product, sale price, date, etc. In some MTS implementations,standard entity tables can be provided for use by all tenants. For CRMdatabase applications, such standard entities can include tables forcase, account, contact, lead, and opportunity data objects, eachcontaining pre-defined fields. As used herein, the term “entity” alsomay be used interchangeably with “object” and “table.”

In some MTS implementations, tenants are allowed to create and storecustom objects, or may be allowed to customize standard entities orobjects, for example by creating custom fields for standard objects,including custom index fields. Commonly assigned U.S. Pat. No.7,779,039, titled CUSTOM ENTITIES AND FIELDS IN A MULTI-TENANT DATABASESYSTEM, by Weissman et al., issued on Aug. 17, 2010, and herebyincorporated by reference in its entirety and for all purposes, teachessystems and methods for creating custom objects as well as customizingstandard objects in a multi-tenant database system. In someimplementations, for example, all custom entity data rows are stored ina single multi-tenant physical table, which may contain multiple logicaltables per organization. It is transparent to customers that theirmultiple “tables” are in fact stored in one large table or that theirdata may be stored in the same table as the data of other customers.

II. Identifying Relational Database Instructions for Validation

FIG. 2 illustrates a database system 200 for relational databaseinstruction validation. The database system 200 may include a validationmodule 213 including one or more validators such as one or more syntaxvalidators 218 and one or more plan validators 219 to generatevalidation indications 229 responsive to receipt of relational databaseinstructions. The database system 200 may include a relational database227, which may be similar to the tenant database 22 (FIG. 1B). Thevalidation indications 229 may be electronically transmitted to anothermodule (not shown) and/or stored in an electronic device (not shown) foranalysis by, for instance, developers.

In some examples, the database system 200 includes a relational databaseinstruction identification module 225, which may be a component tooperate on the application server 100 _(1-N) (FIG. 1B) to controloperation of the relational database 227. The module 225 may beconfigured to, in production, receive information from user systems 12(FIG. 1B) based on user inputs and to identify relational databaseinstructions responsive to receiving such information in production.However, the database system 200 may include a simulated inputgeneration module 211 to feed a simulated user input 212 into the module225 to obtain a candidate relational database instruction 215 forvalidation. Validation indications 229 based on these simulations may beutilized to modify the module 225 prior to production, e.g., beforeactual inputs are received from the user systems 12 (FIG. 1B).

In some examples, the syntax validator(s) 218 may apply rules of adatabase (not shown, such as database system database 24 of FIG. 1B) tovalidate a given relational database instruction. In some examples, theplan validator(s) 219 of the validation module 213 may communicate witha database engine 226 of the relational database 227 to obtain theexplain plan of the relational database instruction to be validated as aplan tree structure.

The database system 200 may include a module 211 to generate thesimulated user input 212 and provide the input 212 to the relationaldatabase instruction identification module 225. In some examples, themodule 211 may include a module to run an f-test to generate thesimulated user input 212 and a module to provide the input 212 to themodule 225.

FIG. 3 illustrates a process that may be performed by the databasesystem 200 of FIG. 2, in some embodiments. In block 301, the databasesystem 200 may identify an instruction generation module configured toautomatically generate relational database instructions based oncommunications from users systems. This may be a candidate instructiongeneration module for production release, for example.

In block 303, the database system 200 may generate a simulated userinput. In block 305, the database system 200 may input the simulateduser input into the instruction generation module to identify acandidate relational database instruction for validation.

In block 307, the database system may analyze the relational databaseinstruction using at least one of a syntax validator or a planvalidator. The syntax validator may also be referred to herein as aparser-based validator and may be configured to use any of the syntaxand/or parsing-based validation techniques described herein. A syntaxvalidator may be configured to parse text of a relational databaseinstruction into a parse tree and identify elements, e.g., predefinedelements, in the parse tree such as tables, columns in filters, columnsin join conditions, hints, or the like, or combinations thereof. Thesyntax validator may be configured to use a rule-based validationchecking responsive to identification of the elements and with respectto the identified elements. In some examples, the rule based validationmay be to meet requirements of the database system (e.g., requirementsof the database engine and/or the application server), and may includeleading index checking, index hint checking, table hint checking, or thelike, or combinations thereof.

A plan validator may be configured to use any of the plan validationtechniques described herein. A plan validator may be configured tointeract with a database engine and/or check an execution plan of therelational database instruction. Some plan validators may be to exchangecommunications with the database engine to obtain an explain plan of theinput relational database instruction as a plan tree structure includingnodes. The plan validator may traverse the tree structure to determinewhether the relational database instruction conforms to predeterminedconditions.

In some examples, the plan validator determines whether the treestructure is associated with predetermined table operations, such asFullScan, FullIndexScan, NestedLoopJoin, HashJoin, or the like, orcombinations thereof. Some plan validators may then check whether thetable operations corresponds to any of predetermined tables and/orcorrespond to a table having a predetermined table attributes (e.g., athreshold size, a threshold quantity of tables, or the like, orcombinations thereof).

Some plan validators may include (or receive information from) a treetransformer module that is configured to parse the relational databaseinstruction into a parse tree to extract transformation information suchas filter columns, join columns, table identities (such as table names,table alias, etc.), or the like, or combinations thereof, in order toidentify the nodes. The extracted transformation may be to be used bythe validators, e.g., by the plan validators and/or the syntaxvalidators.

A plan validator used in the analysis in block 307 may include anynumber of plan validators. Different plan validators may analyzedifferent table operations of the relational database instruction. Forinstance, one plan validator may be configured to ascertain whether therelational database instruction includes a nested loop table operation,and responsive to a result of the ascertainment, identify whether therelational database instruction includes a valid index for columns of ajoin of the nested loop table operation. Another plan validator may beconfigured to ascertain whether the relational database instructionincludes a hash join table operation, and responsive to a result of theascertainment, identify whether the hash join table operation includes afilter. Another plan validator may be configured to ascertain whetherthe relational database instruction includes at least one of a semi-jointable operation or an anti-join table operation, and response to aresult of the ascertainment, identify whether a table operation typeindicated by a plan tree node corresponds to a table operation typeindication by a join hint of the relational database instruction.

In block 208, the database system 200 may store a result of the analysisin a memory device. In some examples, the result of the analysis may beused to automatically or manually identify and/or address performanceissues with the database system to avoid those performance issuesimpacting users (e.g., customers).

FIG. 4 illustrates another database system 400 for relational databaseinstruction validation. The database system 400 may include atransformation module 475 to identify a candidate relational databaseinstruction 465 from a plan file 462 (such as a PL/SQL file). Thetransformation module 475 may also be configured to obtaintransformation information 479 from the candidate relational databaseinstruction 465 and/or the plan file (which may be a result ofprocessing a parse tree), and provide the transformation information 479to the validation module 413. The validation module 413 may be similarto the validation module 213 (and the validators 418 and 419 may besimilar to the validators 218 and 219), and may be configured togenerate validation indications 429 based on the candidate relationaldatabase instruction 415. As such, in some embodiments, a samevalidation component that is utilized for a candidate relationaldatabase instruction 415 (which is similar to the instruction 215 fromFIG. 2) can be utilized for validation of the candidate relationaldatabase instruction 465. In some examples, a database system mayinclude modules 475 and 465, but may not include module 411.

The database 427 and the database engine 426 may be similar to therelational database 227 (FIG. 2) and the database engine 226 (FIG. 2),respectively. The module 425 may be similar to the module 225 (FIG. 2).The module 411 and the simulated user input 412 may be similar to themodule 211 (FIG. 2) and the simulated user input 212 (FIG. 2),respectively.

FIG. 5 illustrates a process that may be performed by the databasesystem 400 of FIG. 4, in some embodiments. In block 501, the databasesystem 400 may identify a candidate file including one or moreprocedural language elements and associated with an instructiongeneration module, such as a module configured to automatically generaterelational database instructions based on communications from usersystems. In some examples, this may be a candidate PL/SQL file or otherplan file to be utilized by the database system 400 in production, forexample.

In block 503, the database system 400 may input the candidate plan fileinto a transformation module. The transformation module may beconfigured to parse a transaction identified by the candidate plan fileinto one or more relational database instructions (e.g., to generatetransformation information and/or to identify a subset of relationaldatabase instructions associated with the candidate plan file). Thedatabase system 400 may obtain a candidate relational databaseinstruction and/or transformation information usable by a plan validatorto validate the candidate relational database instruction responsive toinputting the candidate plan file into the transformation module.

In some examples, the candidate plan file may be a PL/SQL file or someother file based on an enhanced relational database instructionlanguage, e.g., a relational database instruction file based on aprocedural language. The candidate plan file may include more than oneSQL statement, and the transformation information may identify a subsetof these SQL statements. The transformation information may instruct adatabase engine how to obtain an explain plan for the associatedrelational database instruction (which again may be a subset of allrelational database instructions associated with the plan file, in someembodiments).

In block 507, the database system 400 may analyze the relationaldatabase instruction using at least one of a syntax validator or a planvalidator, which may be similar to the validators described in block 307(FIG. 3) and/or may operate according to any validator described herein.At least some of the validators (such as a plan validator) may utilizethe transformation information from the transformation module in block507. In block 509, the database system 400 may store a result of theanalysis in a memory device, which may be similar to block 308 (FIG. 3).

III. Identifying Additional Relational Database Instructions from SystemViews

FIG. 6 illustrates yet another database system 600 for relationaldatabase instruction validation. The database system 600 may include aproduction run module 690 to operate during production to identifyrelational database instructions from system views 691 generated fromdatabase engine 626 of relational database 627 (database engine 626 anddatabase 627 may be similar to database engine 226 (FIG. 2) andrelational database 227 (FIG. 2), respectively). The production runmodule 690 may be configured to provide a relational databaseinstruction 685 to a validation module 613, which be similar tovalidation module 213 (FIG. 2) and may include validators 618 and 619that may similar to validators 218 and 219 (FIG. 2), respectively. Theproduction run module 690 may be implemented as a background job (e.g.,a Cron job based on Cron Expressions, which may indicate intervals forexecuting predetermined processes) of database system 24 (FIG. 1B) insome examples.

The production run module 690 may include an extractor module 695 toexchange communications with the database 627 at scheduled times (e.g.,periodically in some examples) to obtain the system views 691. Theextractor module 695 may be configured to identify relational databaseinstructions from the obtained system views.

The production run module 690 may include a duplicate detector module696. The duplicate detector module 696 may include a memory device tostore information about received system views and/or the identifiedrelational database instructions. The duplicate detector module 696 maybe configured to determine whether a newly identified relationaldatabase instruction is the same as a previously identified relationaldatabase instruction, so that validation may be skipped for duplicates.

The production run module 690 may include a logging and/or monitoringmodule 697 to generate data 699 (which may include log data) based onthe validation indications 629. The data 699 may include raw data andmetrics or other data based on the raw data.

In some examples, a same validation module 613 used to validatecandidate relational database instruction 685 during production can beused for candidate relational database instruction(s) similar toinstructions 215 (FIG. 2) and/or instruction 415 (FIG. 4) prior toproduction. In some examples, a same transformation module may also beused. For instance, the transformation module 675 may be similar to thetransformation module 475 (FIG. 4), and the transformation information677 may be similar to transformation information 470 (FIG. 4).

FIG. 7 illustrates a process that may be performed by the databasesystem 600 of FIG. 6, in some embodiments. In block 701, at a predefinedtime the database system 600 may access a current system view of arelational database. In block 703, the database system 600 may extract arelational database instruction from the current system view.

In block 705, the database system 600 may determine whether to selectany validators of syntax and/or plan validators to operate on therelational database instruction. In some examples, information aboutpreviously accessed system views and/or the relational databaseinstructions extracted therefrom may be stored. Current informationabout the current system view may be compared to the stored informationto determine whether the extracted relational database instruction is aduplicate. The database system 600 may determine to bypass validationfor a duplicate.

The database system 600 may select some or all of the validators to beused for validating a non-duplicate. In some examples, the databasesystem 600 may select a subset of the validators (e.g., plan validators)conditionally based on a current condition associated with the databasesystem 600 (a plan validator may exchange communications with a databaseengine, which can affect performance of the database engine). Forinstance, if a current time corresponds to peak hours of customer use ofthe database system 600, the database system 600 may not select planvalidators (which may communicate with the database engine 626). In someexamples, a backlog may be generated to utilize a plan validator duringoff-peak hours on a relational database instruction identified from asystem view access during on-peak hours.

In some examples, the database system 600 may determine whether theextracted relational database instruction corresponds to any relationaldatabase instructions of any previously accessed system views of therelational database. The database system 600 may analyze the extractedrelational database instruction using at least one validator of morethan one validator based on a result of the determination. The more thanone validator may include at least one of a syntax validator or a planvalidator.

In some examples, the database system 600 may identify at least one of acurrent time or a parameter indicative of a current utilization of adatabase engine of the relational database. The database system 600 mayselect a subset of the validators to be used for validation responsiveto the current time or the parameter, wherein the at least one validatorincludes each validator of the selected subset.

In some examples, the system views may be generated by a database engineof the relational database based on receipt of automatically generatedrelational database instructions and/or may be generated at times basedon a current state of the relational database at those times. Theseinstructions may include SQL statements generated by an applicationserver of the database system 600.

In block 707, the database system 600 may, in response to a selection,analyze the relational database instruction using the selectedvalidator(s). In block 709, the database system may store a result ofthe analysis, which may be similar to block 308 (FIG. 3). In someexamples, in block 707 the database 600 may generate log data based on aresult of the analysis and may store the log data or data derivedtherefrom in a metrics data store. In some examples, the database system600 may provide the result of the analysis to a metric generation moduleto generate metric data based on raw data of the result of the analysisand/or provide the result of the analysis to a logging module togenerate log data responsive to the result of the analysis.

in some examples, the database system 600 may periodically access systemview data of a relational database of the database system. The databasesystem 600 may extract relational database instructions from the systemview data, and analyze at least some of extracted relational databaseinstructions using a syntax validator and/or a plan validator.

In some examples, the database system 600 may determine whether a mostrecently extracted relational database instruction corresponds to anypreviously extracted relational database instructions, and bypassinputting of the most recently extracted relational database instructioninto the validators based on a result of the determination.

In some examples, the database system 600 may input a first relationaldatabase instruction of the relational database instructions into afirst set of the validators, and may input a second different relationaldatabase instruction of the relational database instructions into asecond different set of the validators. One of the sets of thevalidators may be a superset with respect to the other set of thevalidators.

In some examples, the database system 600 may bypass or delay inputtingof a selected relational database instruction of the relational databaseinstructions into only a subset of the validators based on at least oneof a time of day or a parameter indicative of a utilization of thedatabase engine at a time corresponding to extraction of said selectedrelational database instruction. In one example, a selected relationaldatabase instruction may be input into only validators that do notexchange communications with the database engine (e.g., syntaxvalidators); while other relational database instructions may be inputinto those validators and other validators.

The specific details of the specific aspects of implementationsdisclosed herein may be combined in any suitable manner withoutdeparting from the spirit and scope of the disclosed implementations.However, other implementations may be directed to specificimplementations relating to each individual aspect, or specificcombinations of these individual aspects.

Additionally, while the disclosed examples are often described hereinwith reference to an implementation in which an on-demand databaseservice environment is implemented in a database system having anapplication server providing a front end for an on-demand databaseservice capable of supporting multiple tenants, the presentimplementations are not limited to multi-tenant databases or deploymenton application servers. Implementations may be practiced using otherdatabase architectures, i.e., ORACLE®, DB2® by IBM and the like withoutdeparting from the scope of the implementations claimed.

It should also be understood that some of the disclosed implementationscan be embodied in the form of various types of hardware, software,firmware, or combinations thereof, including in the form of controllogic, and using such hardware or software in a modular or integratedmanner. Other ways or methods are possible using hardware and acombination of hardware and software. Additionally, any of the softwarecomponents or functions described in this application can be implementedas software code to be executed by one or more processors using anysuitable computer language such as, for example, Java, C++ or Perlusing, for example, existing or object-oriented techniques. The softwarecode can be stored as a computer- or processor-executable instructionsor commands on a physical non-transitory computer-readable medium.Examples of suitable media include random access memory (RAM), read onlymemory (ROM), magnetic media such as a hard-drive or a floppy disk, oran optical medium such as a compact disk (CD) or DVD (digital versatiledisk), flash memory, and the like, or any combination of such storage ortransmission devices.

Computer-readable media encoded with the software/program code may bepackaged with a compatible device or provided separately from otherdevices (for example, via Internet download). Any such computer-readablemedium may reside on or within a single computing device or an entirecomputer system, and may be among other computer-readable media within asystem or network. A computer system, or other computing device, mayinclude a monitor, printer, or other suitable display for providing anyof the results mentioned herein to a user.

While some implementations have been described herein, it should beunderstood that they have been presented by way of example only, and notlimitation. Thus, the breadth and scope of the present applicationshould not be limited by any of the implementations described herein,but should be defined only in accordance with the following andlater-submitted claims and their equivalents.

What is claimed is:
 1. A database system, comprising: a processingsystem; and a memory device coupled to the processing system andincluding instructions stored thereon that, in response to execution bythe processing system, are operable to: identify an instructiongeneration module configured to automatically generate relationaldatabase instructions based on communications from user systems;generate a simulated user input; input the simulated user input into theinstruction generation module to identify a relational databaseinstruction based on the simulated user input; analyze the relationaldatabase instruction based on the simulated user input using a pluralityof validators including at least one of a syntax validator or a planvalidator; and store a result of the analysis in a memory device.
 2. Thedatabase system of claim 1, wherein the plan validator is configured toascertain whether the relational database instruction includes apredefined table operation to operate on a predefined table type or atable having an attribute corresponding to a predefined attribute. 3.The database system of claim 2, wherein the predefined table operationscomprise at least one of full scan or full index scan.
 4. The databasesystem of claim 2, wherein the predefined table type comprises tableslarger than a threshold size.
 5. The database system of claim 1, whereinthe plan validator is configured to: ascertain whether the relationaldatabase instruction includes a nested loop table operation; andresponsive to a result of the ascertainment, identify whether therelational database instruction includes a valid index for columns of ajoin of the nested loop table operation.
 6. The database system of claim1, wherein the plan validator is configured to: ascertain whether therelational database instruction includes a hash join table operation;and responsive to a result of the ascertainment, identify whether thehash join table operation includes a filter.
 7. The database system ofclaim 1, wherein the plan validator is configured to: ascertain whetherthe relational database instruction includes at least one of a semi-jointable operation or an anti join table operation; and response to aresult of the ascertainment, identify whether a table operation typeindicated by a plan tree node corresponds to a table operation typeindication by a join hint of the relational database instruction.
 8. Thedatabase system of claim 1, wherein the syntax validator comprises aparser-based validator configured to: parse a target relational databaseinstruction into a parse tree, wherein the parse tree includes elementscomprising at least one of tables, columns in filters, columns in joinconditions, or a relational database instruction hint; identify anelement of the elements of the parse tree; and apply a plurality ofrules to the identified element.
 9. The database system of claim 1,wherein the plan validator comprises an explain plan validatorconfigured to obtain an explain plan from a database engine of arelational database.
 10. The database system of claim 9, wherein theexplain plan includes a plan tree structure including a plurality ofnodes.
 11. The database system of claim 1, wherein the plan validator isfurther configured to: compare table operations of a plurality of nodesof a plan tree structure obtained from a relational database to a listof predefined table operations; apply a plurality of rules responsive toa result of the comparison.
 12. The database system of claim 1, whereinthe operations are further operable to: identify a plan file includingone or more procedural language elements to be accessed by the databasesystem during operation of the instruction generation module; identify arelational database instruction corresponding to the plan file; andanalyze the relational database instruction that corresponds to the planfile using the plurality of validators.
 13. The database system of claim12, wherein the database system is further configured to: parse therelational database instruction corresponding to the plan file into aparse tree; and extract, from the parse tree, transformation informationto be used by the plurality of validators.
 14. The database system ofclaim 13, wherein the transformation information includes at least oneof filter columns, join columns, or table identities.
 15. The databasesystem of claim 14, wherein the table identities comprise table names ortable aliases.
 16. A database system, comprising: a processing system;and a memory device coupled to the processing system and includinginstructions stored thereon that, in response to execution by theprocessing system, are operable to: identify an instruction generationmodule configured to automatically generate relational databaseinstructions based on communications from user systems; identify a planfile including one or more procedural language elements to be accessedby the database system during operation of the instruction generationmodule; identify a relational database instruction corresponding to theplan file; and analyze the relational database instruction thatcorresponds to the plan file using a plurality of validators includingat least one of a syntax validator or a plan validator; and store aresult of the analysis in a memory device.
 17. The database system ofclaim 16, wherein the instructions are further operable to generate asimulated user input; input the simulated user input into theinstruction generation module to identify a relational databaseinstruction based on the simulated user input; and analyze therelational database instruction based on the simulated user input usingthe plurality of validators.
 18. The database system of claim 16,wherein the syntax validator comprises a parser-based validatorconfigured to: parse a target relational database instruction into aparse tree, wherein the parse tree includes elements comprising at leastone of tables, columns in filters, columns in join conditions, or arelational database instruction hint; identify an element of theelements of the parse tree; and apply a plurality of rules to theidentified element.
 19. The database system of claim 16, wherein theplan validator comprises an explain plan validator configured to obtainan explain plan from a database engine of a relational database, theexplain plan including a plan tree structure having a plurality ofnodes.
 20. The database system of claim 16, wherein the plan validatoris further configured to: compare table operations of a plurality ofnodes of a plan tree structure obtained from a relational database to alist of predefined table operations; apply a plurality of rulesresponsive to a result of the comparison.